/**
 * 
 */
package name.webdizz.gadget.four.envelope.client.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Izzet_Mustafayev
 * 
 */
public class Person {

	private String name;

	private String identity;

	private List<Expense> expenseList = new ArrayList<Expense>();

	public Person(final String name) {
		this.name = name;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(final String name) {
		this.name = name;
	}

	/**
	 * @return the expenseList
	 */
	public List<Expense> getExpenseList() {
		return expenseList;
	}

	/**
	 * @param expenseList
	 *            the expenseList to set
	 */
	public void setExpenseList(final List<Expense> expenseList) {
		this.expenseList = expenseList;
	}

	public void addExpense(final Expense expense) {
		expenseList.add(expense);
	}

	/**
	 * @return the identity
	 */
	public String getIdentity() {
		return identity;
	}

	/**
	 * @param identity
	 *            the identity to set
	 */
	public void setIdentity(String identity) {
		this.identity = identity;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((identity == null) ? 0 : identity.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Person other = (Person) obj;
		if (identity == null) {
			if (other.identity != null)
				return false;
		} else if (!identity.equals(other.identity))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

}
